import numpy as np
import matplotlib.pyplot as plt

xNum=322
yNum=66
lineWidth=0.25

plt.figure(1,figsize=(20,6))
plt.subplot(1,2,1)
data=np.loadtxt("./mesh/0/points")
xData=data[:,0]
yData=data[:,1]
xMat=xData.reshape(xNum,yNum)
yMat=yData.reshape(xNum,yNum)
for k in range(xNum):
    plt.plot(xMat[k,:],yMat[k,:],color='k',linewidth=lineWidth)
for p in range(yNum):
    plt.plot(xMat[:,p],yMat[:,p],color='k',linewidth=lineWidth)
plt.axis('equal')

plt.figure(1,figsize=(20,6))
plt.subplot(1,2,2)
data=np.loadtxt("./mesh/-1/points")
xData=data[:,0]
yData=data[:,1]
xMat=xData.reshape(xNum,yNum)
yMat=yData.reshape(xNum,yNum)
for k in range(xNum):
    plt.plot(xMat[k,:],yMat[k,:],color='k',linewidth=lineWidth)
for p in range(yNum):
    plt.plot(xMat[:,p],yMat[:,p],color='k',linewidth=lineWidth)
plt.axis('equal')

plt.show()


plt.figure(figsize=(20,6))
data=np.loadtxt("./mesh/residual")
plt.plot(data[:,0],data[:,1],'k')
plt.yscale("log")
plt.xlabel(r"Iteration",fontsize=15)
plt.ylabel(r"Residual",fontsize=15)
plt.xlim(0,data[-1,0])

plt.show();